home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000231_icon-group-sender _Wed Nov 10 09:48:02 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  4KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id JAA29359
  4.     for icon-group-addresses; Wed, 10 Nov 1999 09:47:40 -0700 (MST)
  5. Message-Id: <199911101647.JAA29359@baskerville.CS.Arizona.EDU>
  6. X-Authentication-Warning: agate.berkeley.edu: news set sender to <news> using -f
  7. From: Steve Wampler <swampler@noao.edu>
  8. X-Newsgroups: comp.lang.icon
  9. Subject: Re: List question
  10. Date: Wed, 10 Nov 1999 08:44:04 -0700
  11. X-Trace: noao.edu 942248646 36323 140.252.38.6 (10 Nov 1999 15:44:06 GMT)
  12. X-Complaints-To: abuse@noao.edu
  13. X-Accept-Language: en
  14. To: icon-group@optima.CS.Arizona.EDU
  15. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  16. Status: RO
  17.  
  18. Anders Holtsberg wrote:
  19. > Sorry folks. I just found the very recent discussion on
  20. > this topic on Dejanews. But still: why not let
  21. >     mylist[5+:0] := anotherlist
  22. > be a legal construct? I e the only change would be to
  23. > let mylist[i:j] produce an l-value instead of an r-value,
  24. > it would break no code at all, would it?
  25.  
  26. Correct, this change should have no impact on existing code.
  27.  
  28. > Is the implementation difficult? Are there filosophical
  29. > or implementation problems? (I'm not nagging you guys: I can
  30. > try to do the work if you think the change in semantics is OK).
  31.  
  32. I imagine others will disagree, but I'd like to see at least
  33. an experimental version of Icon with this change in it.  I
  34. assume Anders means to differentiate list sectioning from
  35. list subscripting and have any list section produce an l-value.
  36. This change would bring us one step closer to providing list-scanning.
  37. In fact, it would be possible to then produce a PDCO to experiment
  38. with list-scanning.
  39.  
  40. However, it does require a non-trivial implementation - you'd have
  41. to essentially reproduce internally the same types of operations
  42. that people now have to use externally (though you could apply some
  43. heuristics).
  44.  
  45. For example, implementing:
  46.  
  47.    a[3:5] := [a,b,c,d]
  48.  
  49. would require producing a new list, as if the user had done:
  50.  
  51.    a := a[1:3] ||| [a,b,c,d] ||| a[5:0]
  52.  
  53. (because list element storage is sequential in memory) thus adding
  54. a single element in the middle of a list could have surprisingly
  55. high runtime cost. It has this cost currently, but the fact that
  56. the user has to explicitly code it means it's not a surprise...
  57.  
  58. On the other hand:
  59.  
  60.    a[3:5] := []
  61.  
  62. could (possibly, depending on the desired semantics, see below) be done in
  63. place on the original list, as could a[3:5] := [1] and a[3:5] := [1,2].
  64.  
  65. There are also a few major semantic issues to resolve.  How close to the
  66. behavior
  67. of strings should list section assignment go?  Strings and lists have some
  68. fundamental differences that should be considered carefully.  In particular,
  69. note that, depending on the implementation, there could be a major difference
  70. between
  71.  
  72.    a[3:5] := [a,b,c,d]
  73.  
  74. and
  75.  
  76.    a := a[1:3] ||| [a,b,c,d] ||| a[5:0]
  77.  
  78. (Suppose the assignment b := a is done prior to each of the above
  79. statements. What should the value of b be?).  So list section
  80. assignment does mean that programmers would have to think very carefully
  81. about how they are using lists.  Of course, this is true currently; the
  82. following code catches people sometimes...
  83.  
  84.     a := [1,2,3,4]
  85.     b := a
  86.     a[2] := 5
  87.  
  88. Extending the above behavior to list sectioning is where the direct
  89. implementation becomes complicated.  You'd have to change how lists are
  90. represented and provide "list qualifiers" much as strings are
  91. implemented using string qualifiers.
  92.  
  93. Altering the semantics of list processing to provide even closer semantics
  94. to string processing would be very difficult to implement and would
  95. break existing code (because if you're going to "fix" list sectioning
  96. this way, you'd want to also "fix" list element assignment as well).
  97. I don't think I would be very keen on that drastic of a change.
  98.  
  99. --
  100. Steve Wampler-  SOLIS Project, National Solar Observatory
  101. swampler@noao.edu
  102.